package com.dayuanit.booksystem.v4.mapper;

import com.dayuanit.booksystem.v4.domain.BookInfo;
import com.dayuanit.booksystem.v4.entity.Book;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BookMapper {

    Book getBookById(long bookId);

    @Select("select book_id as id, book_name as bookName, author as author, price as price, publisher_id as publisherId from book where book_name =#{bookName}")
    Book getBookByName(@Param("bookName") String bookName);

    int updateBookName(@Param("bookId") Long Id, @Param("bookName") String bookName);

    int insert(@Param("price") String price,
               @Param("author")String author,
               @Param("bookName")String bookName,
               @Param("publisherId")Long publisherId);

    List<Book> listBook(Long publisherId);

    //根据书的ID查询某本书的作者和价格以及书对应的出版社的名字和地址

    BookInfo getBookInfo(Long bookId);

    //用户可根据书名、作者、出版社ID这三个查询条件，任意选择，查询出作者和价格以及书对应的出版社的名字和地址。
    List<BookInfo> listBookInfo(@Param("bookName") String bookName,
                                @Param("author") String author,
                                @Param("publisherId") Long publisherId,
                                @Param("offset") Integer offset,
                                @Param("pageSize") Integer pageSize);
    int countBookInfo(@Param("bookName") String bookName,
                      @Param("author") String author,
                      @Param("publisherId") Long publisherId);

    List<Book> listBookByPubliserId(List<Long> publisherIds);




}
